<%@ page import="java.util.HashMap,common.CommonUtil,java.util.*,common.*" contentType="text/html; charset=utf-8" %>

<%
UserSession userSession = (UserSession)session.getAttribute("user"); 

//String login_id = null;
String user_id = null;

if(userSession!= null){
	//login_id = userSession.getLogin_id();
	user_id = userSession.getUser_id();
}

String site_url = request.getServerName().replace("http://","");

HashMap listMap=(HashMap)request.getAttribute("list_map");

HashMap map  = null;
ArrayList list=null;


if (listMap!=null){
    list=(ArrayList)listMap.get("mainContent");
}

String ent_id = null;
String ent_nm = null;
String ent_alias = null;
String addr = null;
String start_dt = null;

String close_dt = null;
String use_yn = null;
String service_gubun = null;

String ref_url = null;
String ref_chk_yn = null;
String test_cost = null;
String test_cost_discount = null;

String retest_period = null;

String opic_logo_nm = null;
String opic_logo_id = null;
String ts_logo_nm = null;
String ts_logo_id = null;
String prep_logo_nm = null;
String prep_logo_id = null;
String admin_logo_nm = null;
String admin_logo_id = null;

if(list != null){
	if(list.size() > 0){
		ent_id =  CommonUtil.nvl((String)((HashMap)list.get(0)).get("ent_id"));
		ent_nm = CommonUtil.nvl((String)((HashMap)list.get(0)).get("ent_nm"));
		
		ent_alias = CommonUtil.nvl((String)((HashMap)list.get(0)).get("ent_alias"));
		
		addr =  CommonUtil.nvl((String)((HashMap)list.get(0)).get("addr"));
		
		start_dt = CommonUtil.nvl((String)((HashMap)list.get(0)).get("start_dt"));
		close_dt = CommonUtil.nvl((String)((HashMap)list.get(0)).get("close_dt"));
		use_yn = CommonUtil.nvl((String)((HashMap)list.get(0)).get("use_yn"));
		
		service_gubun = CommonUtil.nvl((String)((HashMap)list.get(0)).get("service_gubun"));
		ref_url = CommonUtil.nvl((String)((HashMap)list.get(0)).get("ref_url"));
		ref_chk_yn = CommonUtil.nvl((String)((HashMap)list.get(0)).get("ref_chk_yn"));
		test_cost = CommonUtil.nvl((String)((HashMap)list.get(0)).get("test_cost"));
		
		test_cost_discount = CommonUtil.nvl((String)((HashMap)list.get(0)).get("test_cost_discount"));
		
		retest_period = CommonUtil.nvl((String)((HashMap)list.get(0)).get("retest_period"));
		
		opic_logo_nm = CommonUtil.nvl((String)((HashMap)list.get(0)).get("opic_logo_nm"));
		opic_logo_id = CommonUtil.nvl((String)((HashMap)list.get(0)).get("opic_logo_id"));
		ts_logo_nm = CommonUtil.nvl((String)((HashMap)list.get(0)).get("ts_logo_nm"));
		ts_logo_id = CommonUtil.nvl((String)((HashMap)list.get(0)).get("ts_logo_id"));
		
		prep_logo_nm = CommonUtil.nvl((String)((HashMap)list.get(0)).get("prep_logo_nm"));
		prep_logo_id = CommonUtil.nvl((String)((HashMap)list.get(0)).get("prep_logo_id"));
		
		admin_logo_nm = CommonUtil.nvl((String)((HashMap)list.get(0)).get("admin_logo_nm"));
		admin_logo_id = CommonUtil.nvl((String)((HashMap)list.get(0)).get("admin_logo_id"));
	}
}


%>
<jsp:include page="/jsp/common/header.jsp"></jsp:include>
<script language='javascript' src="/js/calendar.js"></script>
<script language='javascript' src="/js/common.js"></script>
<script language='javascript' src="/js/validate.js"></script>
<script>
//xml 요청
function getXMLHTTPRequest() {
try {
  req = new XMLHttpRequest();
} catch(err1) {
  try {
  req = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (err2) {
    try {
    req = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (err3) {
      req = false;
    } 
  } 
}
return req;
}


function get_alias_chk_request(id){
  
  var http = getXMLHTTPRequest();
  var myurl = '/speaking.pb?gubun=ent&cmd=id_chk&ent_alias='+id;
  myRand = parseInt(Math.random()*999999999999999);
  var modurl = myurl+"&rand="+myRand;  
  http.open("get", modurl, false);
  //http.onreadystatechange = useHttpResponse;
  http.send(null);
  if (http.readyState == 4) {
    return trim(http.responseText);
  }else{
   return "";
  }
} 

function get_alias_chk(){
	var frm = document.mainform;
	
	var id = document.mainform.ent_alias.value;
	if(id == ''){
		alert('기업 Alias를 입력하세요');
		document.mainform.ent_alias.focus();
		return;
	}
	
	if(!CheckEngStrLen(frm.ent_alias, 1, 20, "기업 Alias")) return false;
	
	for (i=0;i<id.length;i++)   //한글입력을 방지할때
	  {
	   if(id.charCodeAt(i) > 12592)
	   {
		 alert("Alias는 영문과숫자로 조합된 것만 허용됩니다.");
	    document.mainform.ent_alias.value="";
	    document.mainform.ent_alias.focus();
	    return;
	    break;
	   }
	  }
	
	var id_chk_cnt = get_alias_chk_request(id);
	
	if(id_chk_cnt==0){
		document.mainform.id_chk.value='Y';
		alert('입력하신 기업 Alias는 사용할 수 있습니다.');
	}else{
		document.mainform.id_chk.value='N';
		alert('이미 등록된 기업  Alias입니다. 다른 기업  Alias를 등록하세요.');
		document.mainform.ent_alias.focus();
		document.mainform.ent_alias.value='';
	}
}

function trim(str){
	str = str.replace(/(^\s*)|(\s*$)/g,"");
	return str;
}

function num_chk(obj){
	var str = obj.value;
	  for (i=0;i<str.length;i++)
	  {
	   if (!(str.charAt(i) >= 0 && str.charAt(i) <= 9))
	   {
	    alert("숫자만 입력하세요.")
	    obj.value = "";
	    obj.focus();
	    return;
	   }
	  }

}
function go_input(){
var frm = document.mainform;	
	
	
	if(frm.ent_nm.value==''){
		alert('기업명이 비어있습니다.');
		frm.ent_nm.focus();
		return;
	}	
	
	if(!CheckStrLen(frm.ent_nm, 1, 200, "기업명")) return false;
	
	if(frm.ent_alias.value==''){
		alert('Alias가 비어있습니다.');
		frm.ent_alias.focus();
		return;
	}
	
	if(!CheckEngStrLen(frm.ent_alias, 1, 20, "기업 Alias")) return false;
	
	if(frm.start_dt.value==''){
		alert('시작일이 비어있습니다.');
		frm.start_dt.focus();
		return;
	}
	
	if(frm.close_dt.value==''){
		alert('종료일이 비어있습니다.');
		frm.close_dt.focus();
		return;
	}
	
	var start_dt_arr = frm.start_dt.value.split('-');
	if(start_dt_arr.length > 1){
		var s_year = start_dt_arr[0];
		var s_month = Lpad(start_dt_arr[1], 2);
		var s_day = Lpad(start_dt_arr[2], 2);
		
		frm.start_dt.value = s_year+''+s_month+''+s_day;
	}
	
	var close_dt_arr = frm.close_dt.value.split('-');
	if(close_dt_arr.length > 1){
		var e_year = close_dt_arr[0];
		var e_month = Lpad(close_dt_arr[1], 2);
		var e_day = Lpad(close_dt_arr[2], 2);
		
		frm.close_dt.value = e_year+''+e_month+''+e_day;
	}
	
	if(frm.retest_period.value==''){
		alert('재응시기간이 비어있습니다.');
		frm.retest_period.focus();
		return;
	}
	
	if(frm.test_cost.value==''){
		alert('테스트비용이 비어있습니다.');
		frm.test_cost.focus();
		return;
	}
	
	
	frm.cmd.value='ent_modify';
	frm.action = '/speaking.pb?cmd=ent_modify';
	frm.target= 'hidden_frm';              
	frm.submit();	
}

function go_ent(){
	var frm = document.mainform;	
	frm.cmd.value='ent_main';
	frm.action = '/speaking.pb?cmd=ent_main';
	frm.target= '_self';              
	frm.submit();	
}
</script>

<jsp:include page="/jsp/common/top.jsp"></jsp:include>
<jsp:include page="/jsp/common/submenu.jsp"><jsp:param name="submenu_id" value="ent_main" /><jsp:param name="submenu_idx" value="1" /></jsp:include>

<form name="mainform"  method="post" action = "/speaking.pb" enctype= "multipart/form-data">
	<div id="bodyContainer">
        <div id="contents">
          <jsp:include page="/jsp/common/submenu_list.jsp"><jsp:param name="submenu_id" value="ent_main" /><jsp:param name="submenu_idx" value="3" /></jsp:include>
          
          
          <div class="boxContainer">
            <dl title="기업수정">
              <dt>기업수정</dt>
            </dl>
            <table class="setupTb">
            
              <tr>
                <th>기업명</th>
                <td><input type="text" name="ent_nm" id="ent_nm" style="width:200px" value="<%= ent_nm%>"/></td>
              </tr>
              <tr>
                <th>기업 Alias</th>
                <td><%= ent_alias%> <input type="hidden" name="ent_alias" id="ent_alias" style="width:200px" value="<%= ent_alias%>"/></td>
                <!-- 
                <td><input type="text" name="ent_alias" id="ent_alias" style="width:200px" value="<%= ent_alias%>"/> <a href="#" onclick="get_alias_chk()"><input type="button" value="중복체크" style="width:100px; height:20px"></a> </td>
                 -->
              </tr>
              <!--  
              <tr>
                <th>주소</th>
                <td><input type="text" name="addr" id="addr" style="width:300px" value="<%= addr%>"/></td>
              </tr>
              -->
              <tr>
                <th>시작일</th>
                <td><input type="text" name="start_dt" id="start_dt" style="width:100px" value="<%= start_dt%>" OnFocus="cal(<%=CommonUtil.getToday("yyyy") %>,<%=CommonUtil.getToday("MM") %>,<%=CommonUtil.getToday("dd") %>,this);" /> </td>
              </tr>
              <tr>
                <th>종료일</th>
                <td><input type="text" name="close_dt" id="close_dt" style="width:100px" value="<%= close_dt%>" OnFocus="cal(<%=CommonUtil.getToday("yyyy") %>,<%=CommonUtil.getToday("MM") %>,<%=CommonUtil.getToday("dd") %>,this);" /> </td>
              </tr>
              <input type="hidden" name="use_yn" id="use_yn" value='Y' />
              <!--  
              <tr>
                <th>사용구분</th>
                <td><input type="radio" name="use_yn" id="use_yn" value='Y' <%=(use_yn.equals("Y"))?"checked":"" %>/>사용 <input type="radio" name="use_yn" id="use_yn" value='N' <%=(use_yn.equals("N"))?"checked":"" %>/>미사용</td>
              </tr> 
              -->
              <tr>
                <th>서비스유무</th>
                <td><input type="radio" name="service_gubun" id="service_gubun" value='Y' <%=(service_gubun.equals("Y"))?"checked":"" %>/>서비스 <input type="radio" name="service_gubun" id="service_gubun" value='N' <%=(service_gubun.equals("N"))?"checked":"" %>/>서비스안함</td>
              </tr> 
              
              <!-- 
              <tr>
                <th>레퍼런스URL</th>
                <td><input type="text" name="ref_url" id="ref_url" style="width:300px" value="<%= ref_url%>"/></td>
              </tr> 
              <tr>
                <th>레퍼런스사용유무</th>
                <td><input type="radio" name="ref_chk_yn" id="ref_chk_yn" value='Y' <%=(ref_chk_yn.equals("Y"))?"checked":""%> />사용 <input type="radio" name="ref_chk_yn" id="ref_chk_yn" value='N' <%=(ref_chk_yn.equals("N"))?"checked":""%>/>미사용</td>
              </tr> 
               -->
               <input type="hidden" name="ref_url">
               <input type="hidden" name="ref_chk_yn" value="N">
              <tr>
                <th>재응시기간</th>
                <td><input type="text" name="retest_period" id="retest_period" style="width:25px" value="<%= retest_period%>" onkeydown="num_chk(this);" onkeyup="num_chk(this);"/>(일)</td>
              </tr> 
              
              <%if(!site_url.equals("solution.dkeol.com")){ %>
              <tr>
                <th>OPIC 테스트 로고</th>
                <td>
                  <input type="file" name="attachFile" id="attachFile" style="width:200px"/>
                  <%if(!opic_logo_id.equals("")){ %>
	                <br>                
	                <img src="/speaking.pb?cmd=download2&file_id=<%=opic_logo_id %>&file_name=<%=opic_logo_id %>&file_folder=datas" />
	              <%} %>
              </tr>
              
              <tr>
                <th>T/S 테스트 로고</th>
                <td>
                  <input type="file" name="attachFile_1" id="attachFile_1" style="width:200px"/>
                  <%if(!ts_logo_id.equals("")){ %>
	                <br>                
	                <img src="/speaking.pb?cmd=download2&file_id=<%=ts_logo_id %>&file_name=<%=ts_logo_id %>&file_folder=datas" />
	              <%} %>
              </tr>
              
              <tr>
                <th>Speaking Test Prep 테스트 로고</th>
                <td>
                  <input type="file" name="attachFile_3" id="attachFile_3" style="width:200px"/>
                  <%if(!prep_logo_id.equals("")){ %>
	                <br>                
	                <img src="/speaking.pb?cmd=download2&file_id=<%=prep_logo_id %>&file_name=<%=prep_logo_id %>&file_folder=datas" />
	              <%} %>
              </tr>
              
              <tr>
                <th>관리자 로고</th>
                <td>
                  <input type="file" name="attachFile_2" id="attachFile_2" style="width:200px"/>
                  <%if(!admin_logo_id.equals("")){ %>
	                <br>                
	                <img src="/speaking.pb?cmd=download2&file_id=<%=admin_logo_id %>&file_name=<%=admin_logo_id %>&file_folder=datas" />
	              <%} %>
              </tr>
              <%} %>
              
              <tr>
                <th>테스트비용</th>
                <td><input type="text" name="test_cost" id="test_cost" style="width:100px" value="<%= test_cost%>" onkeydown="num_chk(this);" onkeyup="num_chk(this);" />
                (실제 적용되지 않습니다. 기업관리 시 내부적으로 참고하시기 바랍니다.)</td>
              </tr> 
              <tr>
                <th>할인가</th>
                <td><input type="text" name="test_cost_discount" id="test_cost_discount" style="width:100px" value="<%= test_cost_discount%>" onkeydown="num_chk(this);" onkeyup="num_chk(this);" />
                (실제 적용되지 않습니다. 기업관리 시 내부적으로 참고하시기 바랍니다.)</td>
              </tr>            
            </table>
            <p><a href="#" onclick="go_input()"><img src="img/btn_modify.gif" alt="수정" width="49" height="20" /></a> <a href="#" onclick="go_ent()"><img src="img/btn_list.gif" alt="목록" width="49" height="20" /></a> </p>
            
          </div>
          
        </div>
      </div>


<input type="hidden" name="cmd" value="">
<input type="hidden" name="user_id" value="<%=user_id %>">
<input type="hidden" name="ent_id" value="<%=ent_id %>">

<input type="hidden" name="opic_logo_nm" value="<%=opic_logo_nm %>">
<input type="hidden" name="opic_logo_id" value="<%=opic_logo_id %>">
<input type="hidden" name="ts_logo_nm" value="<%=ts_logo_nm %>">
<input type="hidden" name="ts_logo_id" value="<%=ts_logo_id %>">

<input type="hidden" name="prep_logo_nm" value="<%=prep_logo_nm %>">
<input type="hidden" name="prep_logo_id" value="<%=prep_logo_id %>">

<input type="hidden" name="admin_logo_nm" value="<%=admin_logo_nm %>">
<input type="hidden" name="admin_logo_id" value="<%=admin_logo_id %>">

<input type="hidden" name="id_chk" value="N">

</form>

<iframe name='hidden_frm'  width='0' height='0' SCROLLING='AUTO' frameborder='0'></iframe>
<jsp:include page="/jsp/common/footer.jsp"></jsp:include>
<jsp:include page="/jsp/common/bottom.jsp"></jsp:include>
